<template>
	<view class="">
		<view class="editPage">
			<view class="title">
				调整预计验收时间
			</view>
			<view class="centerview">
				<view class="list">
					<text>业主预约验收时间</text>
					<view class="flex-row">
						<input type="text" placeholder="" v-model="dateIpt" disabled="true" style="width: 140rpx;">
						<input type="text" placeholder="" v-model="isTime" disabled="true">
					</view>
				</view>
				<view class="list" style="margin-top: 30rpx;">
					<text >请输入预计验收时间</text>
					<picker mode="date" :value="timeIpt" @change="bindDateChange" style="margin: 20rpx 0;">
						<view class="uni-input">
							<text class="text_4">{{timeIpt}}</text>
						</view>
					</picker>
				</view>
			</view>
			<view class="btn">
				<text @click="surebtn">确认</text>
			</view>
			<view class="closebtn" @click="closebtn()">
				<image :src="$IMG_URL+'index/roung.png'" mode="" />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			const currentDate = this.getDate({
				format: true
			})
			return {
				dateIpt:'',
				isTime:'',
				timeIpt:'',
				acceptanceServiceId:'',
				ordersId:'',
				timeIpt:currentDate
			}
		},
		onLoad(option) {
			// console.log(option);
			this.acceptanceServiceId = option.acceptanceServiceId;
			this.ordersId = uni.getStorageSync('ordersId');
			this.getdata();
		},
		created() {
			uni.startPullDownRefresh();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			bindDateChange: function(e) {
				this.timeIpt = e.detail.value
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
			
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			surebtn(){
				let obj={}
				if(this.dateIpt !=0 && this.timeIpt!=0){
					const ordersId = uni.getStorageSync('ordersId');
					this.$http('version.updatetime',{
						acceptanceServiceId:this.acceptanceServiceId,
						estimateTime:this.timeIpt,
					}).then(res=>{
						if(res.code==200){
							uni.navigateTo({
								url:'pages/onSite/onSiteIndex/checkEx/checkEx'
							})
						}
					})
					
				}else{
					uni.showToast({
						icon: 'none',
						title: '请输入时间'
					});
				}
				
				
			},
			getdata(){
				this.$http('common.getInfolist',{
					ordersId:this.ordersId,
					type:'6'
				}).then(res=>{
					console.log(res,'验收列表22')
					if(res.code ==200){
						this.dateIpt = res.data.isData;
						this.isTime = res.data.isTime;
					}
				})
			},
			closebtn(){
				uni.navigateBack({
					delta:1
				})
				
			}
		}
	}
</script>

<style scoped lang="scss">
page{
	background-color: rgba(0, 0, 0, 0.6);
}
.editPage{
	width: 70%;
	height: 500rpx;
	background-color: #fff;
	position: absolute;
	top: 30%;
	left: 15%;
	border-radius: 28rpx;
}
.title{
	color:#333333 ;
	font-size: 30rpx;
	text-align: center;
	font-weight: 600;
	height: 80rpx;
	line-height:80rpx;
}
.list{
	border-bottom: 1px solid #eee;
	color: #333;
	font-size: 26rpx;
	width: 80%;
	margin: 20rpx auto;
}
.list input{
	font-size: 22rpx;
	color: #666;
	margin: 20rpx 0;
}
.btn{
	width: 80%;
	height: 60rpx;
	margin: 0 auto;
	background-color:#1A76F2;
	border-radius: 36rpx;
	text-align: center;
	font-size:30rpx;
	color: #fff;
	line-height: 60rpx;
}
.closebtn{
	position: absolute;
	top: 10rpx;
	right: 10rpx;
	width: 40rpx;
	height: 40rpx;
}
.closebtn image{
	width: 100%;
	height: 100%;
}
</style>
